package com.yanyu.space.common.gateway.filter.support;

import com.yanyu.space.common.gateway.filter.LogFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.route.Route;
import org.springframework.web.server.ServerWebExchange;

import java.net.URI;
import java.time.LocalDateTime;

/**
 * @author gz
 */
public class DefaultLogPrint implements ILogPrint{
    private static final Logger LOGGER = LoggerFactory.getLogger(LogFilter.class);
    @Override
    public void print(URI finalOriginUri, Route route, URI url, ServerWebExchange exchange) {
        LOGGER.info("转发请求：{}://{}{} --> 目标服务：{}，目标地址：{}://{}{}，转发时间：{}",
                finalOriginUri.getScheme(), finalOriginUri.getAuthority(), finalOriginUri.getPath(),
                route.getId(), url.getScheme(), url.getAuthority(), url.getPath(), LocalDateTime.now());
    }
}
